<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Banner
 * 
 * @property int $id
 * @property int $type
 * @property string|null $url
 * @property string|null $link
 * @property int $goods_id
 * @property string|null $name
 * @property int $sort
 * @property Carbon|null $create_at
 * @property Carbon|null $update_at
 * @property Carbon|null $delete_at
 *
 * @package App\Models
 */
class Banner extends BaseModels
{
    use SoftDeletes;

    const TYPE_INDEX = 1; //首页banner

    const SHARE_BACK = 2; //分享二维码背景

    const JOIN_BACK = 3; //合伙人入驻

	protected $table = 'zh_banner';

	protected $fillable = [
		'type',
		'url',
		'link',
        'goods_id',
		'name',
        'sort',
		'create_at',
		'update_at',
		'delete_at'
	];

	protected $appends = [
	    'type_name'
    ];


    /**
     * @return string
     */
	public function getTypeNameAttribute()
    {
        switch ($this->type){
            case self::TYPE_INDEX:
                return '首页幻灯片';
            case self::SHARE_BACK:
                return '海报背景';
            case self::JOIN_BACK:
                return '合伙人入驻';
            default:
                return '未知';
        }
    }

}
